--精神爆发
local race_jingshengbaofa = fk.CreateSkill {
    name = "mcdh_race_jingshengbaofa"
}

local U = require "packages/utility/utility"
local lib = require "packages/mcdh/lib"

race_jingshengbaofa:addEffect('viewas',{
    pattern = ".",
    prompt = "#race_jingshengbaofa-use",
    expand_pile = "qingxuxishou_pile",
    card_filter = function(self,player, to_select, selected)
        if #selected == 0  then
            return not player:prohibitDiscard(to_select) and player:getPileNameOfId(to_select) ~= "qingxuxishou_pile"
        elseif #selected == 1  then
            return player:getPileNameOfId(to_select) == "qingxuxishou_pile"
        else
            return false
        end
    end,
    view_as = function(self, cards)
        if #cards ~= 2 then
            return nil
        end
        local trueCard = Fk:getCardById(cards[2])
        self.cost_data = cards[1]
        return trueCard
    end,
    before_use = function(self, player, use)
        local room = player.room
        room:throwCard(self.cost_data, self.name, player, player)
    end,
    after_use = function (self, player, use)
        player:drawCards(1, self.name)
    end,
    enabled_at_play = function(self, player)
        return #player:getPile("qingxuxishou_pile") > 0
    end,
    enabled_at_response = function(self, player)
        return #player:getPile("qingxuxishou_pile") > 0
    end,
})

Fk:loadTranslationTable {
    ["mcdh_race_jingshengbaofa"] = "精神爆发",
    [":mcdh_race_jingshengbaofa"] = "你可以弃置一张牌并使用或打出武将牌上的牌，然后摸一张牌。",
    ["#mcdh_race_jingshengbaofa_delay"] = "精神爆发",
    ["#race_jingshengbaofa-use"] = "精神爆发: 选择一张弃置的牌和一张使用的牌"
}

return race_jingshengbaofa